WABT bindings for Rust
Rust bindings for WABT. Work in progress.
Usage
Add this to your Cargo.toml
:
[]
= "0.9.0"
Example
wat2wasm
(previously known as wast2wasm
):
extern crate wabt;
use wat2wasm;
wasm2wat
:
extern crate wabt;
use wasm2wat;
wabt
can be also used for parsing the official testsuite scripts.
use ;
let wast = r#"
;; Define anonymous module with function export named `sub`.
(module
(func (export "sub") (param $x i32) (param $y i32) (result i32)
;; return x - y;
(i32.sub
(get_local $x) (get_local $y)
)
)
)
;; Assert that invoking export `sub` with parameters (8, 3)
;; should return 5.
(assert_return
(invoke "sub"
(i32.const 8) (i32.const 3)
)
(i32.const 5)
)
"#;
let mut parser = from_str?;
while let Some = parser.next?